<script type="text/javascript">
	function doSearchCustomerOfferPrice(value) {
		
	}
	
	//表格查询  
	function reloadCustomerOfferPrice() {
		var params = customerOfferPrice_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		customerOfferPrice_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		customerOfferPrice_list.datagrid('unselectAll');
		customerOfferPrice_list.datagrid('uncheckAll');
	}


	function addCustomerOfferPrice() {
		createFromWindow("新增信息", "customerOfferPrice.do?editCustomerOfferPrice", "customerOfferPrice.do?saveCustomerOfferPrice",
				function(data) {
					reloadCustomerOfferPrice();
				});
	}
	
	function deleteCustomerOfferPrice() {
		var rows = customerOfferPrice_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('customerOfferPrice.do?deleteCustomerOfferPriceItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadCustomerOfferPrice();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editCustomerOfferPrice() {
		var rows = customerOfferPrice_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "customerOfferPrice.do?editCustomerOfferPrice&customerOfferPriceId=" + rows[0].id,
					"customerOfferPrice.do?saveCustomerOfferPrice", function(data) {
						reloadCustomerOfferPrice();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	//操作按钮触发
	function operationsLookCustomerOfferPrice(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = customerOfferPrice_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "customerOfferPrice.do?editCustomerOfferPrice&customerOfferPriceId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditCustomerOfferPrice(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = customerOfferPrice_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "customerOfferPrice.do?editCustomerOfferPrice&customerOfferPriceId=" + id,
					"customerOfferPrice.do?saveCustomerOfferPrice", function(data) {
						reloadCustomerOfferPrice();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendCustomerOfferPrice() {
		printLog('发送');
	}
	
	function operationsDeleteCustomerOfferPrice(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('customerOfferPrice.do?deleteCustomerOfferPriceItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadCustomerOfferPrice(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function clearCustomerOfferPriceSearch() {
		setGridSearchParams('customerOfferPrice_list','customerOfferPriceSearchForm',true,reloadCustomerOfferPrice);
	}
	
	//根据条件查询
	function customerOfferPriceSearch() {
		setGridSearchParams('customerOfferPrice_list','customerOfferPriceSearchForm',false,reloadCustomerOfferPrice);
	}
	
	function createCustomerOfferPrice() {
		var rows = customerSetPrice_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要重新生成报价单吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('customerOfferPrice.do?createCustomerOfferPrice',{customerIds:ids},function(result){
	                    if (result.success){
	                    	reloadCustomerOfferPrice();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请勾选对应客户记录.");
	    }
	}
	
	function sureCustomerOfferPrice() {
		var rows = customerSetPrice_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	    	if(rows.length>1) {
				showMsg('请选择一条客户记录进行创建.');
				return;
			}
	        $.messager.confirm('询问','你确认要重新创建报价单吗?',function(r){
	            if (r){
	            	var sureRows = customerOfferPrice_list.datagrid("getRows"); 
// 	            	printLog(sureRows);
	                $.post('customerOfferPrice.do?sureCustomerOfferPrice',{data:JSON.stringify(sureRows)},function(result){
	                    if (result.success){
	                    	reloadCustomerOfferPrice();    
	                    }
	                    showMsg(result.msg,2000);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请勾选对应客户记录.");
	    }
	}
	
	function exportCustomerOfferPrice() {
		var rows = customerSetPrice_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	    	if(rows.length>1) {
				showMsg('请选择一条客户记录进行创建.');
				return;
			}
	    	printLog(rows);
	    	downLoadFile("customerOfferPrice.do?exportCustomerOfferPrice&customerName="+rows[0].name+"&customerId="+rows[0].id);
	    }else {
	    	showMsg("请勾选对应客户记录.");
	    }
	}
</script>
<script type="text/javascript">
	
	//表格查询  
	function reloadCustomerSetPrice() {
		var params = customerSetPrice_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		customerSetPrice_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		customerSetPrice_list.datagrid('unselectAll');
		customerSetPrice_list.datagrid('uncheckAll');
	}
	
	function clearcustomerSetPriceSearch() {
		setGridSearchParams('customerSetPrice_list','customerSetPriceSearchForm',true,reloadCustomerSetPrice);
	}
	
	//根据条件查询
	function customerSetPriceSearch() {
		setGridSearchParams('customerSetPrice_list','customerSetPriceSearchForm',false,reloadCustomerSetPrice);
	}
	
 	
	function onClickCustomerSetPriceItem(rowData) {
		printLog(rowData);
		var params = $('#customerOfferPrice_list').datagrid('options').queryParams;
		params['customerId'] = rowData.id;
		//设置好查询参数 reload 一下就可以了 
		$('#customerOfferPrice_list').datagrid('reload');
	}
</script>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region: 'west', title: '客户列表',border:false, split: true," style="width: 580px;">
		<@eu.datagrid id="customerSetPrice_list" toolbar="#customerSetPrice_search" idField="id" selectOnCheck="true" 
			 url="customerInfo.do?loadList" rownumbers="true" onClickRow="onClickCustomerSetPriceItem(rowData)"
			 item="com.xdtech.ad.vo.CustomerInfoItem"/>
		
		<div id="customerSetPrice_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="customerSetPriceSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="customerSetPriceSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearcustomerSetPriceSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="customerInfo_toolbar" style="height: auto">
				<@eu.linkbutton showName="刷新" shiro="ad:customerInfo:refresh" iconCls="icon-reload" onclick="reloadCustomerSetPrice()"/>
				
			</div>
		</div>
	</div>
	<div data-options="region:'center',border:false,title: '报价列表'">
		
		<@eu.datagrid id="customerOfferPrice_list" toolbar="#customerOfferPricelist_search" idField="id" 
			 url="customerOfferPrice.do?loadList" rownumbers="true" pageSize="300" autoEditing="true"
			 item="com.xdtech.ad.vo.CustomerOfferPriceItem"/>
		
		<div id="customerOfferPricelist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="customerOfferPriceSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="customerOfferPriceSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearCustomerOfferPriceSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="customerOfferPrice_toolbar" style="height: auto">
				<@eu.linkbutton showName="生成报价清单" shiro="ad:customerOfferPrice:createOfferPrice" iconCls="icon-add" onclick="createCustomerOfferPrice()"/>
<!-- 				<@eu.linkbutton showName="新增" shiro="ad:customerOfferPrice:add" iconCls="icon-add" onclick="addCustomerOfferPrice()"/> -->
				<@eu.linkbutton showName="删除" shiro="ad:customerOfferPrice:delete" iconCls="icon-remove" onclick="deleteCustomerOfferPrice()"/>
<!-- 				<@eu.linkbutton showName="编辑" shiro="ad:customerOfferPrice:edit" iconCls="icon-edit" onclick="editCustomerOfferPrice()"/> -->
				<@eu.linkbutton showName="创建客户报价单" shiro="ad:customerOfferPrice:createOfferPrice" iconCls="icon-add" onclick="sureCustomerOfferPrice()"/>					
				<@eu.linkbutton showName="导出客户报价单" shiro="ad:customerOfferPrice:exportOfferPrice" iconCls="icon-add" onclick="exportCustomerOfferPrice()"/>	
				<@eu.linkbutton showName="刷新" shiro="ad:customerOfferPrice:refresh" iconCls="icon-reload" onclick="reloadCustomerOfferPrice()"/>
			</div>
		</div>
	</div>
</div>